<template>
	<div>
		
	</div>
</template>

<script>
//axios配置参数都有哪些
import axios from 'axios'
export default {
  name: 'four',
  components: {
  },
  created() {
	axios.create({
		baseUrl:'http://localhost:8081',//请求的域名，基本地址
		timeout:1000,//请求超时时长（毫秒）
		url:'/data.json',//请求路径
		method:'get,post,put,patch,delete',//请求方法
		headers:{token:''},//请求头
		params:{},//请求参数在url
		data:{},//请求参数在请求体里
	})
	//axios全局配置 (低优先级)
	axios.defaults.timeout = 1000
	axios.defaults.baseURL = 'http://localhost:8081'
	//axios实例配置 (中优先级)
	let instance = axios.create()//不加参数即为全局配置
	instance.defaults.timeout = 3000
	//axios请求配置 (高优先级)
	instance.get('/data.json',{
		timeout:1000
	})
	//实际开发
	//有两种请求接口
	//http://localhost8080
	//http://localhost8080
	let instance2 = axios.created({
		baseUrl:'http://localhost:8080',
		timeout:1000
	})
	let instance3 = axios.created({
		baseUrl:'http://localhost:8081',
		timeout:1000
	})
	//baseUrl,timeout,url,method,params
	instance2.get('/contactList',{
		params:{}
	}).then((res)=>{
		console.log(res)
	})
	instance3.get('/orderList',{
		timeout:5000//延迟变成5000ms
	}).then(res=>{
		console.log(res)
	})
  }
}
</script>

<style>
</style>
